package friend;

import java.util.List;

import com.example.androidhw06_tab.MyFriend;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class FriendAdapter extends BaseAdapter{

	public static final int ITEM_COUNT=1;
	public static final int ITEM_FRIEND = 0;
	
	List<MyFriend> mFriends;
	Context mContext;
	
	public FriendAdapter(Context context, List<MyFriend> list){
		mContext = context;
		mFriends = list;
//		mFriends.add(new MyFriend("user1", "msg1"));
//		mFriends.add(new MyFriend("user2", "msg2"));
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mFriends.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mFriends.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return ITEM_COUNT;
	}
	
	@Override
	public int getItemViewType(int position) {
		return ITEM_FRIEND;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		MyFriend friend = mFriends.get(position);
		FreindView view;
		
		if(convertView == null){
			view = new FreindView(mContext);
		}else{
			view = (FreindView)convertView;
		}
	//	view.setData(friend);
		return view;
		
		
	}

}
